package com.vmont.encodeapp.activity.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.vmont.encodeapp.R;
import com.vmont.encodeapp.adapter.VideoDevAdapter;
import com.vmont.encodeapp.bean.DevBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class VideoFragment extends Fragment {

    private View view;

    @BindView(R.id.rv_dev_list)
    RecyclerView recyclerView;

    private List<DevBean> datas;

    private VideoDevAdapter devAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreateView(inflater, container, savedInstanceState);
        view = inflater.inflate(R.layout.fragment_video, null);
        ButterKnife.bind(this,view);
        initView();
        return view;
    }


    private void initView() {

        getDevs();
    }


    private void getDevs() {
        datas = new ArrayList<>();
        DevBean devBean;
        for (int i = 0; i < 15; i++) {
            devBean = new DevBean();
            datas.add(devBean);
        }
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 3);
        recyclerView.setLayoutManager(gridLayoutManager);
        devAdapter = new VideoDevAdapter(R.layout.item_video_dev, datas);
        recyclerView.setAdapter(devAdapter);
        devAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

            }
        });
    }

}
